package com.isunland.managesystem.ui;

import com.google.gson.Gson;
import com.isunland.managesystem.base.BaseNetworkDialogFragment;
import com.isunland.managesystem.common.ApiConst;
import com.isunland.managesystem.entity.CurrentUser;
import com.isunland.managesystem.entity.CustomerDialog;
import com.isunland.managesystem.entity.DictionaryTreeContent;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * 对象功能: 可用调休类型
 * 开发公司: 北京信普达系统工程有限公司
 * 开发人员: HuXiaoDan
 * 创建时间: 2016/4/8 17:00
 */
public class ChooseOffTypeDialogFragment extends BaseNetworkDialogFragment {
  @Override public ArrayList<CustomerDialog> resolveResponse(String arg0) {
    ArrayList<CustomerDialog> list = new ArrayList<>();

    DictionaryTreeContent[] dataList = new Gson().fromJson(arg0, DictionaryTreeContent[].class);

    if (dataList == null || dataList.length == 0) {

      return null;
    }
    for (DictionaryTreeContent aDataList : dataList) {
      if ("03".equalsIgnoreCase(aDataList.getCustomAttrs()) || "04".equalsIgnoreCase(
          aDataList.getCustomAttrs())) {
        continue;
      }
      list.add(new CustomerDialog(aDataList.getName(), aDataList.getCustomAttrs()));
    }
    return list;
  }

  @Override public String getUrl() {
    return ApiConst.URL_DATA_DICTIONARY_LIST;
  }

  @Override public HashMap<String, String> getparameters() {
    HashMap<String, String> params = new HashMap<>();
    params.put("dictFlg", "hrHolyKindCode");
    params.put("memCode", CurrentUser.newInstance(getActivity()).getMemberCode());
    return params;
  }
}
